import {fromJS} from "immutable";
import {types} from "@/store/home/Article";

const defaultData = fromJS({
    ArticleList: [],
    // 当前Page页数
    ArticleCurrentPage: 1,
    // 总共Page页数
    ArticleTotalPage: 1,
    // 一个Page页内展示的用户信息数量
    ArticleListPageSize: 10,
    // 总计文章数
    ArticleCounts: 0
})


const Article = (state = defaultData, {type, value}) => {
    switch (type) {
        case types.ARTICLE_SET_DATA:
            return state.set('ArticleList', value);
        case types.ARTICLE_SET_PAGE:
            return state.set('ArticleCurrentPage', value);
        case types.ARTICLE_SET_TOTAL_PAGE:
            return state.set('ArticleTotalPage', value);
        case types.ARTICLE_SET_SIZE:
            return state.set('ArticleListPageSize', value);
        case types.ARTICLE_SET_TOTAL:
            return state.set('ArticleCounts', value);
        case types.ARTICLE_OBJECT_VALUE:
            return state.merge(value);
        default:
            return state;
    }
}
export default Article;
